//
//  SecondViewController.m
//  UI_21_通知
//
//  Created by dllo on 15/11/6.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "SecondViewController.h"
#import "ThirdViewController.h"
@interface SecondViewController ()

@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    UIButton *bti = [UIButton buttonWithType:UIButtonTypeCustom];
    bti.backgroundColor = [UIColor yellowColor];
    bti.frame = CGRectMake(100, 100, 100, 100);
    [self.view addSubview:bti];
    [bti addTarget:self action:@selector(BUTTONACTION:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    //要改变颜色
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeColor:) name:@"changeColor" object:nil];
    
}
- (void)changeColor:(NSNotification *)notification{
    //    NSNotification *是父亲
    UIColor *color = [notification object];
    self.view.backgroundColor = color;

}

- (void)BUTTONACTION:(UIButton *)btu{
    ThirdViewController *th = [[ThirdViewController alloc]init];
    [self.navigationController pushViewController:th animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
